
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>pymatgen.io.aiida &#8212; pymatgen 2020.3.2 documentation</title>
    <link rel="stylesheet" href="../../../_static/proBlue.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../../_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.3.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.aiida</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) AiiDA Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>


<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module provides conversion between AiiDA StructureData object and</span>
<span class="sd">pymatgen Molecule/Structure objects.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Andrius Merkys&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2015, AiiDA Development Team&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;1.0&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Andrius Merkys&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;andrius.merkys@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Oct 9, 2015&quot;</span>

<span class="kn">from</span> <span class="nn">monty.dev</span> <span class="k">import</span> <span class="n">requires</span>
<span class="kn">import</span> <span class="nn">warnings</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">aiida.orm</span> <span class="k">import</span> <span class="n">DataFactory</span>
    <span class="kn">from</span> <span class="nn">aiida.common.exceptions</span> <span class="k">import</span> <span class="n">MissingPluginError</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">StructureData</span> <span class="o">=</span> <span class="n">DataFactory</span><span class="p">(</span><span class="s1">&#39;structure&#39;</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">MissingPluginError</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ImportError</span>
    <span class="n">aiida_loaded</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="n">aiida_loaded</span> <span class="o">=</span> <span class="kc">False</span>


<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;The pymatgen.io.aiida module is deprecated and does not work with&quot;</span>
              <span class="s2">&quot;Aiida &gt;= 1.0. It will be removed in pmg 2020. Pls install the &quot;</span>
              <span class="s2">&quot;aiida package if you need to convert pmg objects to Aiida objects.&quot;</span><span class="p">)</span>


<div class="viewcode-block" id="AiidaStructureAdaptor"><a class="viewcode-back" href="../../../pymatgen.io.aiida.html#pymatgen.io.aiida.AiidaStructureAdaptor">[docs]</a><span class="nd">@requires</span><span class="p">(</span><span class="n">aiida_loaded</span><span class="p">,</span> <span class="s2">&quot;To use the AiidaStructureAdaptor, you need to have &quot;</span>
                        <span class="s2">&quot;aiida installed.&quot;</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">AiidaStructureAdaptor</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adaptor serves as a bridge between AiiDA StructureData and pymatgen</span>
<span class="sd">    Molecule/Structure objects.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_structuredata</span><span class="p">(</span><span class="n">structure</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns AiiDA StructureData object from pymatgen structure or</span>
<span class="sd">        molecule.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure: pymatgen.core.structure.Structure or</span>
<span class="sd">                       pymatgen.core.structure.Molecule</span>

<span class="sd">        Returns:</span>
<span class="sd">            AiiDA StructureData object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">StructureData</span><span class="p">(</span><span class="n">pymatgen</span><span class="o">=</span><span class="n">structure</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_molecule</span><span class="p">(</span><span class="n">structuredata</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns pymatgen molecule from AiiDA StructureData.</span>

<span class="sd">        Args:</span>
<span class="sd">            structuredata: AiiDA StructureData object</span>

<span class="sd">        Returns:</span>
<span class="sd">            pymatgen.core.structure.Molecule</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">structuredata</span><span class="o">.</span><span class="n">get_pymatgen_molecule</span><span class="p">()</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_structure</span><span class="p">(</span><span class="n">structuredata</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns pymatgen structure from AiiDA StructureData.</span>

<span class="sd">        Args:</span>
<span class="sd">            structuredata: AiiDA StructureData object</span>

<span class="sd">        Returns:</span>
<span class="sd">            pymatgen.core.structure.Structure</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">structuredata</span><span class="o">.</span><span class="n">get_pymatgen_structure</span><span class="p">()</span></div>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.3.2 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>